﻿namespace fleetIt.Core
{
    using System.Windows.Data;
    using System.Windows.Media;
    using System.Globalization;
    using System;

    [ValueConversion(typeof(int), typeof(SolidColorBrush))]
    public class CharacterCounter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                if ((int)value > 140)
                {
                    return new SolidColorBrush(Colors.Red);
                }
                else
                {
                    return new SolidColorBrush(Colors.Black);
                }
            }
            else
            {
                return null;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }

        #endregion
    }
}
